﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MDIApplication
{
    public partial class GuestRoomReport : Form
    {
        public GuestRoomReport()
        {
            InitializeComponent();
        }

        private void GuestRoomReport_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'ReportDataSet.GuestRoom' table. You can move, or remove it, as needed.
            this.GuestRoomTableAdapter.Fill(this.ReportDataSet.GuestRoom);
            dateTimePicker1.Value = DateTime.Today;
            dateTimePicker2.Value = DateTime.Today;
            this.reportViewer1.RefreshReport();
        }

        private void reportViewer1_Load(object sender, EventArgs e)
        {
            this.reportViewer1.RefreshReport();
        }

        private void btnsearch_Click(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'ReportDataSet.GuestRoom' table. You can move, or remove it, as needed.
            this.GuestRoomTableAdapter.FillByRoom(this.ReportDataSet.GuestRoom, Convert.ToInt32(tbxsearchrm1.Text));
            this.reportViewer1.RefreshReport();
        }

        private void btnsearch2_Click(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'ReportDataSet.Guest' table. You can move, or remove it, as needed.
            lbldate.Text = dateTimePicker1.Value.ToShortDateString() + " To " + dateTimePicker2.Value.ToShortDateString();
            this.GuestRoomTableAdapter.FillByDate(this.ReportDataSet.GuestRoom, Convert.ToString(dateTimePicker1.Text), Convert.ToString(dateTimePicker2.Text));
            this.reportViewer1.RefreshReport();

            if (dateTimePicker1.Value > dateTimePicker2.Value)
            {
                MessageBox.Show("Incorrect (From) Date", "Error Message");
            }
        }

        private void tbxsearchrm1_KeyPress(object sender, KeyPressEventArgs e)
        {
            char ch = e.KeyChar;
            if (!Char.IsDigit(ch) && ch != 8)
            {
                e.Handled = true;
                MessageBox.Show("Please Enter Numbers Only", "Error Message");
            }
        }

        private void btnviewall_Click(object sender, EventArgs e)
        {
            this.GuestRoomTableAdapter.Fill(this.ReportDataSet.GuestRoom);
            this.reportViewer1.RefreshReport();
        }
    }
}
